{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Logistic Regression for Imbalanced Classification"
      ],
      "metadata": {
        "nteract": {
          "transient": {
            "deleting": false
          }
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "from collections import Counter\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# yahoo finance is used to fetch data \n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-11T01:34:11.707Z",
          "iopub.execute_input": "2022-05-11T01:34:11.711Z",
          "shell.execute_reply": "2022-05-11T01:34:12.233Z",
          "iopub.status.idle": "2022-05-11T01:34:12.218Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2019-01-01'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume\nDate                                                    \n2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400\n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200\n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300\n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100\n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-11T01:34:12.222Z",
          "iopub.execute_input": "2022-05-11T01:34:12.227Z",
          "iopub.status.idle": "2022-05-11T01:34:12.886Z",
          "shell.execute_reply": "2022-05-11T01:34:12.903Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset['Open_Close'] = (dataset['Open'] - dataset['Adj Close'])/dataset['Open']\n",
        "dataset['High_Low'] = (dataset['High'] - dataset['Low'])/dataset['Low']\n",
        "dataset['Increase_Decrease'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],1,0)\n",
        "dataset['Buy_Sell_on_Open'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],1,0)\n",
        "dataset['Buy_Sell'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],1,0)\n",
        "dataset['Returns'] = dataset['Adj Close'].pct_change()\n",
        "dataset = dataset.dropna()\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume  Open_Close  \\\nDate                                                                   \n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200   -0.005025   \n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300   -0.029925   \n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100    0.002387   \n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700    0.011820   \n2014-01-09  4.20  4.23  4.05   4.09       4.09  30667600    0.026190   \n\n            High_Low  Increase_Decrease  Buy_Sell_on_Open  Buy_Sell   Returns  \nDate                                                                           \n2014-01-03  0.030928                  1                 1         1  0.012658  \n2014-01-06  0.047619                  1                 1         1  0.032500  \n2014-01-07  0.034063                  0                 1         0  0.012106  \n2014-01-08  0.028986                  0                 0         0  0.000000  \n2014-01-09  0.044444                  0                 0         1 -0.021531  ",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Open_Close</th>\n      <th>High_Low</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>-0.005025</td>\n      <td>0.030928</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.012658</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>-0.029925</td>\n      <td>0.047619</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032500</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>0.002387</td>\n      <td>0.034063</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012106</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>0.011820</td>\n      <td>0.028986</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>2014-01-09</th>\n      <td>4.20</td>\n      <td>4.23</td>\n      <td>4.05</td>\n      <td>4.09</td>\n      <td>4.09</td>\n      <td>30667600</td>\n      <td>0.026190</td>\n      <td>0.044444</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.021531</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-11T01:34:12.893Z",
          "iopub.execute_input": "2022-05-11T01:34:12.896Z",
          "shell.execute_reply": "2022-05-11T01:34:12.962Z",
          "iopub.status.idle": "2022-05-11T01:34:12.918Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset[['Open', 'High', 'Low', 'Volume', 'Adj Close','Returns']].values\n",
        "y = dataset['Buy_Sell'].values"
      ],
      "outputs": [],
      "execution_count": 4,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "shell.execute_reply": "2022-05-11T01:34:12.964Z",
          "iopub.status.busy": "2022-05-11T01:34:12.923Z",
          "iopub.execute_input": "2022-05-11T01:34:12.927Z",
          "iopub.status.idle": "2022-05-11T01:34:12.933Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "counter = Counter(y)\n",
        "print(counter)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Counter({0: 631, 1: 626})\n"
          ]
        }
      ],
      "execution_count": 5,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-11T01:34:12.938Z",
          "iopub.execute_input": "2022-05-11T01:34:12.942Z",
          "iopub.status.idle": "2022-05-11T01:34:12.950Z",
          "shell.execute_reply": "2022-05-11T01:34:12.967Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "for label, _ in counter.items():\n",
        "\trow_ix = np.where(y == label)[0]\n",
        "\tplt.scatter(X[row_ix, 0], X[row_ix, 1], label=str(label))\n",
        "plt.legend()\n",
        "plt.show()"
      ],
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<Figure size 432x288 with 1 Axes>",
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAm30lEQVR4nO3de3zcdZ3v8ddnkkmbttjQpEKTUC7qooCV2pSFQ0UWFjiihIIShaPWA1J2veCF01JQa6mXlqKirOulAivuIhilhFJXsIscMexjgZRACirLQeDRJIXSSyKlaZtkPuePmUmTyUxmMpdkfsn7+XiUJL+55FMCn377+X2+n6+5OyIiEjyh8Q5ARESyowQuIhJQSuAiIgGlBC4iElBK4CIiAVU6lt+sqqrKjznmmLH8liIigbdly5ad7j478fqYJvBjjjmGlpaWsfyWIiKBZ2YvJ7uetoRiZlPN7HEze9rMnjWzG2LXf2pmL5rZU7FfJ+c5ZhERGUEmK/ADwFnuvtfMwkCzmf0m9tgyd/9V4cITEZFU0iZwj27V3Bv7Mhz7pe2bIiLjLKMauJmVAFuAtwL/7O6Pmdk/At8ws5XAQ8AKdz+Q5LVLgaUAc+fOHfbevb29tLe3s3///ux/FwU2depUamtrCYfD4x2KiMgAG80sFDOrAO4FPgvsAl4ByoD1wAvuvnqk19fV1XniTcwXX3yRww47jMrKSsxsdNGPAXdn165dvP766xx77LHjHY6ITEJmtsXd6xKvj6oP3N27gIeB/+nu2z3qAPAvwCnZBLZ///6iTd4AZkZlZWVR/w1BRIpTU2sHp6/9Hceu+DWnr/0dTa0deX3/TLpQ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CMjPYIT4A8Gj9sa+DMd+OXAW8KvY9aL9958pJfDMOPBbM9tiZkvHO5gcHOHu22OfvwIcMZ7BZOkzZtYWK7EUZfkhkZkdA8wHHiOAP4OE+CEgPwMzKzGzp4AdwGbgBaDL3ftiT2knQH8oJaMEnplF7v5u4H3Ap2N/vQ80j9bOglY/+yHwFuBkYDvw7XGNJgNmNgO4B/i8u/918GNB+BkkiT8wPwN373f3k4Fa4BTg7eMbUf4pgWfA3TtiH3cA9xL9jyGIXo3VNuM1zh3jHM+ouPursf8pI8BPKPKfQ6z2eg9wp7tviF0OzM8gWfxB+xkAuHsX8DBwGlBhZvGjJGuBjvGKKx+UwNMws+mxmziY2XTgXOCZkV9VtDYCS2KfLwHuG8dYRi2e+GIuooh/DrGbaLcBf3L37wx6KBA/g1TxB+VnYGazzawi9nk5cA7ROv7DwIdiTyvaf/+ZUhdKGmZ2HNFVN0TPVP65u39jHEPKiJndBZxJdHzmq8BXgSagEZhLdKxvg7sX5Y3CFPGfSfSv7g68BFw1qJ5cVMxsEfAHYCsQiV2+nmgdueh/BiPEfykB+BmY2TyiNylLiC5UG919dez/57uBWUAr8FF3PzB+keZGCVxEJKBUQhERCSglcBGRgFICFxEJKCVwEZGAUgIXEQkoJXARkYBSAhcRCaj/DzXL6r6irAifAAAAAElFTkSuQmCC\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-11T01:34:12.954Z",
          "iopub.execute_input": "2022-05-11T01:34:12.958Z",
          "iopub.status.idle": "2022-05-11T01:34:13.062Z",
          "shell.execute_reply": "2022-05-11T01:34:13.080Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import cross_val_score\n",
        "from sklearn.model_selection import RepeatedStratifiedKFold\n",
        "from sklearn.linear_model import LogisticRegression\n",
        "\n",
        "model = LogisticRegression(solver='lbfgs')\n",
        "# define evaluation procedure\n",
        "cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)\n",
        "# evaluate model\n",
        "scores = cross_val_score(model, X, y, scoring='roc_auc', cv=cv, n_jobs=-1)\n",
        "# summarize performance\n",
        "print('Mean ROC AUC: %.3f' % np.mean(scores))"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mean ROC AUC: 0.480\n"
          ]
        }
      ],
      "execution_count": 7,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-11T01:34:13.068Z",
          "iopub.execute_input": "2022-05-11T01:34:13.072Z",
          "iopub.status.idle": "2022-05-11T01:34:16.095Z",
          "shell.execute_reply": "2022-05-11T01:34:16.099Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.13",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "argv": [
        "C:/Users/Tin Hang/Anaconda3\\python.exe",
        "-m",
        "ipykernel_launcher",
        "-f",
        "{connection_file}"
      ],
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "nteract": {
      "version": "0.28.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}